package com.example.utils

import android.app.Activity

object ActivityController {
    private val activities = ArrayList<Activity>()

    fun addActivity(activity: Activity){
        this.activities.add(activity)
    }

    fun removeActivity(activity: Activity){
        this.activities.remove(activity)
    }

    fun finishAll(){
        for (activity in this.activities){
            if(!activity.isFinishing){
                activity.finish()
            }
        }
        activities.clear()
        //杀掉当前进程的代码 只能用于杀掉当前程序的进程
        android.os.Process.killProcess(android.os.Process.myPid())
    }
}